import wxRequest from '../index'
import { IAccount, IDataType, ILoginResult, IUserInfo } from './types'
enum LoginAPI {
  AccountLogin = '/login', //登录
  userInfo = '/users/', //获取用户信息
  UserMenus = '/role/' //不同用户不同菜单 /role/1/menu
}
export function accountLoginRequest(account: IAccount) {
  return wxRequest.post<IDataType<ILoginResult>>({
    url: LoginAPI.AccountLogin,
    data: account,
    showLoading: true
  })
}
export function requestUserInfoById(id: number) {
  return wxRequest.get<IUserInfo>({
    url: LoginAPI.userInfo + id,
    showLoading: true
  })
}

export function requestUserMenusByRoleId(id) {
  return wxRequest.get<IDataType>({
    url: LoginAPI.UserMenus + id + '/menu'
  })
}
